package com.laity.event;

import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author: Laity
 * @Project: JavaLaity
 * @Package: com.laity.event.CustomEventListener
 * @Date: 2023年11月21日 11:03
 * @Description: 事件接收器
 */
@Component
public class CustomEventListener {

    // condition 支持EL表达式
    // #event.message == 'demo' 表示 if 的意思；等于执行，不等于不执行
    @EventListener(condition = "#event.message == 'msg publisher test'")
    @Async
    public void receivedMsg(CustomEvent event) {
        System.out.println("received msg：" + event.getMessage());
        System.out.println(Thread.currentThread().getName() + "-ok");
    }

}
